import request from '@/utils/request'
import {Message } from 'element-ui'
import { error } from 'util'

// 获取任务list
export function getTasks(data, succCb) {
  return request({
    url: 'tasks/',
    method: 'get',
    params: data
  }).then(res => {
    succCb(res)
  }).catch(() => {
    console.log('getTasks-->>')
  })
}

// 添加任务
export function addTask(data, succCb) {
  return request({
    url: 'tasks/',
    method: 'post',
    data
  }).then(res => {
    succCb(res)
  }).catch(() => {
    console.log('addTask-->>')
  })
}

// 任务详情
export function taskDetail(id, data, succCb) {
  return request({
    url: 'tasks/' + id + '/details',
    method: 'get',
    params: data
  }).then(res => {
    succCb(res)
  }).catch(() => {
    console.log('taskDetail-->>')
  })
}

// 任务操作-开始/暂停
export function taskOper(id, data, succCb) {
  return request({
    url: 'tasks/' + id,
    method: 'put',
    data
  }).then(res => {
    succCb(res)
  }).catch(() => {
    console.log('taskOper-->>')
  })
}

// 获取角色list
export function getRoles(succCb) {
  return request({
    url: 'roles/',
    method: 'get'
  }).then(res => {
    succCb(res)
  }).catch(() => {
    console.log('-->>users-get')
  })
}

//获取用户最小间隔和最大呼叫次数
export function getUsersLimited(succCb){
  return request({
    url: 'users/limited',
    method: 'get'
  }).then(res => {
    succCb(res)
  }).catch(() => {
    console.log('-->>users/limited-get')
  })
}